package com.old.controller;


import com.old.service.OssService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

//@Controller
public class UploadController2 {
    private final OssService ossService;

    public UploadController2(OssService ossService) {
        this.ossService = ossService;
    }


//    @RequestMapping("/uploadMultipartFile")
//    @ResponseBody
    public String fileUpload(MultipartFile multipartFile){
        if(multipartFile.isEmpty()){
            return "请选择上传文件！！";
        }

        return ossService.uploadFile(multipartFile);
    }


//    @RequestMapping("/uploadFile")
//    @ResponseBody
    public String fileUpload(@RequestParam("file") File file){
        if(!file.exists()){
            return "请选择上传文件！！";
        }


        return ossService.uploadFile(file);
    }
}
